home *** CD-ROM | disk | FTP | other *** search
/ C# & Game Programming - A…er's Guide (2nd Edition) / Buono 2nd Ed.iso / Chapter2 / 2.2 / 2.2.cs next >
Encoding:
Text File  |  2004-08-31  |  469 b   |  22 lines

  1. /* Using the if statement. */
  2. using System;
  3.  
  4. namespace Chapter2 {
  5.     class Class1 {
  6.         static void Main() {
  7.             int cResponse;  
  8.  
  9.             // Step 1
  10.             Console.Write("Input <Y> for YES:  ");   
  11.  
  12.             // Step 2
  13.             cResponse = Console.Read();
  14.     
  15.             // Step 3 - if response equals 'Y'
  16.             if ((char) cResponse == 'Y') 
  17.                 Console.WriteLine("\n You typed Y\n");
  18.         }
  19.     }
  20. }
  21.  
  22.